<template>
    <div class="goodList">
        <div class="topnav">
            <div class="bx">
                <span :class="{borderStyle:current==1}" @click="funA">
                    全部
                </span>
                <span :class="{borderStyle:current==2}" @click="funP">
                    直播
                </span>
                <span :class="{borderStyle:current==3}" @click="funO">
                    精选
                </span>
                <span :class="{borderStyle:current==4}" @click="funL">
                    低至9.9
                </span>
            </div>
        </div>
        <div class="bottomList">
            <van-swipe class="my-swipe" :autoplay="3000" indicator-color="white" v-if="current==1">
                <van-swipe-item v-for="(v,index) in banner" :key="index">
                    <img :src="v.img" alt="">
                </van-swipe-item>
            
            </van-swipe>
            <List v-for="(v, index) in arr" :key="index" :img1="v.img1" :proname="v.proname" :originprice="v.originprice" :sales="v.sales" :flag="false" @click.native="goDetail1(v)"></List>
        </div>
    </div>
</template>

<script>
import List from '@/components/xn/HomeCom/Goods/List.vue'


export default {
    name:"goodsList",
    data(){
        return {
            current:1,
            arr:[],
            banner:[]
        }
    },
    methods:{
        funA(){
            this.current = 1
             this.$http({
            url:`http://118.178.238.19:3001/api/pro/recommendlist`,
            method:"get",
            params:{
                count:this.current
            }
        }).then(res=>{
            this.arr = res.data.data
            console.log(res.data.data)
        })
        },
        funP(){
            this.current = 2
             this.$http({
            url:`http://118.178.238.19:3001/api/pro/recommendlist`,
            method:"get",
            params:{
                count:this.current
            }
        }).then(res=>{
            this.arr = res.data.data
            console.log(res.data.data)
        })
        },
        funO(){
            this.current = 3
             this.$http({
            url:`http://118.178.238.19:3001/api/pro/recommendlist`,
            method:"get",
            params:{
                count:this.current
            }
        }).then(res=>{
            this.arr = res.data.data
            console.log(res.data.data)
        })
        },
        funL(){
            this.current = 4
             this.$http({
            url:`http://118.178.238.19:3001/api/pro/recommendlist`,
            method:"get",
            params:{
                count:this.current
            }
        }).then(res=>{
            this.arr = res.data.data
            console.log(res.data.data)
        })
        },
        goDetail1(v) {
         this.$router.push({
            path: '/detail',
            query: {
               delList: JSON.stringify(v)
            }
         })
        },
    },
    mounted(){
        this.$http({
            url:`http://118.178.238.19:3001/api/pro/recommendlist`,
            method:"get",
            params:{
                count:this.current
            }
        }).then(res=>{
            this.arr = res.data.data
            console.log(res.data.data)
        })
        this.$http({
            url:`http://localhost:3000/localBanner`,
            method:"get",
        }).then(res=>{
            this.banner = res.data
        })
    },
    components:{
        List
    }
}
</script>

<style lang="scss" scoped>
    .goodList {
        min-height: 11.96rem;
        width: 100%;
        background: #fff;
        border-top-left-radius: 0.2rem;
        border-top-right-radius: 0.2rem;
    }
    .goodList .topnav {
        width: 100%;
        height: 1.1rem;
    }
    .goodList .topnav .bx {
        width: 6.53rem;
        height: 100%;
        margin: auto;
        display: flex;
        justify-content: space-between;
        align-items: center;
        font-size: 0.3rem;
        color: #4f5047;
    }
    .goodList .topnav .bx span {
        height: 0.48rem;
        box-sizing: border-box;
    }
    .goodList .topnav .bx .borderStyle {
        border-bottom: 0.05rem solid #61d500;
        color: #70d742;
    }
    .goodList .bottomList {
        width: 7.12rem;
        margin: auto;
        column-count: 2;
    }
    .goodList .bottomList .van-swipe {
        width: 3.48rem;
        height: 5.03rem;
        border-radius: 0.15rem;
        overflow: hidden;
    }

    .goodList .bottomList .van-swipe img {
        width: 3.48rem;
        height: 5.03rem;
    }
</style>